package com.example.leetcode;

/**
 * 回文数字问题
 */
public class Demo0009 {

    public static void main(String[] args) {
        System.out.println(isValid(12321));
    }
    public static boolean isValid(int n){
        if (n<0 || (n%10==0 && n!=0)){
            return false;
        }
        int reverse=0;
        while (n>reverse){
            reverse=reverse*10+n%10;
            n=n/10;
        }
        return n==reverse || reverse/10==n;
    }
}
